package com.song.email.dao.mongodb.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.song.email.bean.Work;
import com.song.email.dao.mongodb.BaseDao;


@Service("emailWorkDao")
@Transactional
public class EmailWorkDao implements BaseDao<Work>{
	private Log logger = LogFactory.getLog(EmailWorkDao.class);

	@Resource(name = "mongoTemplate")
	private MongoTemplate mongoTemplate;

	public void insertAll(List<Work> workList) {
		try {
			mongoTemplate.insertAll(workList);
			logger.debug(">>>mongoDB>>>>批量添加Work成功...个数:" + workList.size() + "条");
		} catch (Exception e) {
			logger.error("添加Auth出错...", e);
		}
	}

	public void insert(Work work) {
		try {
			mongoTemplate.insert(work);
			logger.debug(">>>mongoDB>>>>添加Work成功...个数:1条");
		} catch (Exception e) {
			logger.error("添加Auth出错...", e);
		}
		
	}

}
